﻿Imports System.Net.Sockets

''' <summary>
''' Encapsulates a Winsock client, associated network stream, data read buffer, and async result.
''' </summary>
''' <remarks></remarks>
Public Structure ClientInfo
    ''' <summary>
    ''' Gets the TcpClient for the remote host.
    ''' </summary>
    ''' <remarks></remarks>
    Public ReadOnly Client As TcpClient
    ''' <summary>
    ''' Gets the network stream associated with the client.
    ''' </summary>
    ''' <remarks></remarks>
    Public ReadOnly Stream As NetworkStream
    ''' <summary>
    ''' Gets the last operation's async result.
    ''' </summary>
    ''' <remarks></remarks>
    Public AsyncResult As IAsyncResult
    ''' <summary>
    ''' Gets the buffer used for reading data from the stream.  For internal use only; read
    ''' incomming data from the ReceivedData structure.
    ''' </summary>
    ''' <remarks></remarks>
    Public ReadOnly ReadBuffer() As Byte
    ''' <summary>
    ''' Gets the length of the buffer used for reading data from the stream.
    ''' </summary>
    ''' <returns>The length of the buffer.</returns>
    ''' <remarks></remarks>
    Public ReadOnly Property ReadBufferLength As Integer
        Get
            Return ReadBuffer.Length
        End Get
    End Property

    Public Sub New(forClient As TcpClient)
        Client = forClient
        Stream = forClient.GetStream
        ReDim ReadBuffer(Client.ReceiveBufferSize - 1)
    End Sub
End Structure
